<!DOCTYPE html>
<html lang="en">
<head>
    <title>iot系统登录页面</title>
    <meta charset="UTF-8">
    <script src="../scripts/jquery.min.js"></script>
    <script src="../scripts/miniui/miniui.js"></script>
    <link rel="stylesheet" href="../scripts/miniui/themes/default/miniui.css">

    <script type="text/javascript">
        mini.parse();


        function submitForm() {


            //提交表单数据
            var form = new mini.Form("#form1");
            var data = form.getData();      //获取表单多个控件的数据
            $.ajax({
                url: "/auth/webGetToken",
                type: "post",
                data: data,
                success: function (resp) {
                    if (resp.code!=200){
                        alert("登录失败")
                        return;
                    }
                    var ret=resp.data;
                    document.cookie=ret.userId+"="+ret.token;
                    window.location.href="/static/html/main.html";
                }
            });

        }

    </script>
</head>
<body>
<div id="form1" style="display: grid; place-items: center;">

    <table>
        <tr>
            <td>用户名</td>
            <td>
                <mini-textbox   name="userName" required="true"></mini-textbox>
            </td>


        </tr>
        <tr>
            <td>密码</td>
            <td>
                <mini-textbox   name="pwd" required="true"></mini-textbox>
            </td>
        </tr>
        <tr>
            <td>
                <a class="mini-button" onclick="submitForm()" >登录</a>
            </td>
        </tr>
    </table>
</div>
</body>
</html>